﻿@page "/Archive/Supplier/Index"
@page "/Archive/Supplier/Index/{Token}"
@using iTeamyou.LTS.UI.Models;
@using iTeamyou.LTS.UI.Shared.Components;

@*@inject IStringLocalizer<Core.Models.Supplier> SupplierLocalizer*@

<h5 style="margin-top: 1.5rem;">管理供应商</h5>
<div style="margin-top: 2rem;">
    @*<GroupBox Title="搜索条件">
            <div class="row g-3 form-inline">
                <div class="col-12 col-sm-3">
                    <BootstrapInput @bind-Value="@SearchModel.IdOrName" PlaceHolder="请输入供应商编码" maxlength="50" ShowLabel="true" />
                </div>
                <div class="col-12 col-sm-3">
                    <BootstrapInput @bind-Value="@SearchModel.CreateFrom" PlaceHolder="创建开始日期" maxlength="50" ShowLabel="true" />
                </div>
                <div class="col-12 col-sm-3">
                    <BootstrapInput @bind-Value="@SearchModel.CreateTo" PlaceHolder="创建结束日期" maxlength="500" ShowLabel="true" />
                </div>
                <div class="col-12 col-sm-3">
                    <Button Text="搜索" OnClick="@(e => OnSearchModelQueryAsync())" />
                </div>
            </div>
        </GroupBox>*@
    <Button Text="新建供应商" OnClick="@AddSupplier" IsDisabled="IsUnauth" />
    <Button Text="编辑" OnClick="@EditSupplierBtn" IsDisabled="@(SelectedSuppliers.Count != 1)" />
    @*<PopConfirmButton Color="Color.Danger" IsDisabled="@(SelectedSuppliers.Count == 0)" OnConfirm="(() => DeleteSuppliers(SelectedSuppliers))" ConfirmIcon="fa-solid fa-triangle-exclamation text-danger" ConfirmButtonColor="Color.Danger" Content="确定删除选中的记录吗？">删除</PopConfirmButton>*@
    <Button Text="导出" OnClick="@Export" IsDisabled="IsUnauth" />
</div>
@*
*@
<Table style="margin-top: 1rem;" TItem="Core.Models.Supplier"
       IsPagination="true" PageItemsSource="@PageItemsSource" IsStriped="true" ShowLineNo="true"
       CustomerSearchModel="@SupplierSearchModel" SearchMode="SearchMode.Top" ShowSearchText="true" ShowSearch="true"
       OnDoubleClickRowCallback="@EditSupplier"
       SelectedRows="@SelectedSuppliers" SelectedRowsChanged="@SelectChanged" IsMultipleSelect="true"
       ShowSkeleton="true" ShowResetButton="true" ShowEmpty="true"
       OnQueryAsync="@OnQueryAsync" IsAutoRefresh="@IsAutoRefresh" AutoRefreshInterval="2000">
    <TableColumns>
        <TableColumn @bind-Field="@context.SId" Width="80" />
        <TableColumn @bind-Field="@context.Name" Width="200" />
        <TableColumn @bind-Field="@context.Contact" Width="100" />
        <TableColumn @bind-Field="@context.Region" Width="40" Filterable="true" />
        <TableColumn @bind-Field="@context.CreatedOn" Width="80" Sortable="true" />
        <TableColumn @bind-Field="@context.Status" Width="40" Filterable="true" />
        <TableColumn @bind-Field="@context.LastModifiedOn" Width="80" Sortable="true" />
        <TableColumn @bind-Field="@context.LicenseNum" Width="80" Text="证照数">
            <Template Context="value">
                @if (value.Value == 0)
                {
                    <Tag Color="Color.Dark">共 0 个证照</Tag>
                }
                else
                {
                    <Tag Color="Color.Primary">共 @value.Value 个证照</Tag>
                }
            </Template>
            @*<FilterTemplate>
                <LicenseCountFilter />
            </FilterTemplate>*@
        </TableColumn>
    </TableColumns>
    <CustomerSearchTemplate>
        @if (context is SupplierSearchModel model)
        {
            <SupplierSearch @bind-Value="@model" />
        }
    </CustomerSearchTemplate>
</Table>